package com.imut.lagain.entity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

import java.time.LocalDateTime;

/**
 * 数据操作日志实体类
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("data_operation_log")
public class DataOperationLog {
    private static final Logger log = LoggerFactory.getLogger(DataOperationLog.class);

    
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    
    /**
     * 操作用户ID
     */
    @TableField("user_id")
    private Long userId;
    
    /**
     * 操作类型（CREATE, UPDATE, DELETE, READ等）
     */
    @NotBlank(message = "操作类型不能为空")
    @Size(max = 50, message = "操作类型长度不能超过50个字符")
    @TableField("operation_type")
    private String operationType;
    
    /**
     * 操作的表名
     */
    @NotBlank(message = "表名不能为空")
    @Size(max = 100, message = "表名长度不能超过100个字符")
    @TableField("table_name")
    private String tableName;
    
    /**
     * 操作的记录ID
     */
    @TableField("record_id")
    private Long recordId;
    
    /**
     * 操作前的数据（JSON格式）
     */
    @TableField("old_data")
    private String oldData;
    
    /**
     * 操作后的数据（JSON格式）
     */
    @TableField("new_data")
    private String newData;
    
    /**
     * 操作描述
     */
    @Size(max = 500, message = "操作描述长度不能超过500个字符")
    @TableField("description")
    private String description;
    
    /**
     * 客户端IP地址
     */
    @Size(max = 45, message = "IP地址长度不能超过45个字符")
    @TableField("ip_address")
    private String ipAddress;
    
    /**
     * 用户代理信息
     */
    @Size(max = 500, message = "用户代理信息长度不能超过500个字符")
    @TableField("user_agent")
    private String userAgent;
    
    /**
     * 操作时间
     */
    @TableField(value = "operation_time", fill = FieldFill.INSERT)
    private LocalDateTime operationTime;
    
    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    public void setUserId(Long userId) {
        this.userId = userId;
    }
    
    public Long getUserId() {
        return userId;
    }
    
    public void setOperationType(String operationType) {
        this.operationType = operationType;
    }
    
    public String getOperationType() {
        return operationType;
    }
    
    public void setTableName(String tableName) {
        this.tableName = tableName;
    }
    
    public String getTableName() {
        return tableName;
    }
    
    public void setRecordId(Long recordId) {
        this.recordId = recordId;
    }
    
    public Long getRecordId() {
        return recordId;
    }
    
    public void setOldData(String oldData) {
        this.oldData = oldData;
    }
    
    public String getOldData() {
        return oldData;
    }
    
    public void setNewData(String newData) {
        this.newData = newData;
    }
    
    public String getNewData() {
        return newData;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }
    
    public String getIpAddress() {
        return ipAddress;
    }
    
    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }
    
    public String getUserAgent() {
        return userAgent;
    }
    
    public void setOperationTime(LocalDateTime operationTime) {
        this.operationTime = operationTime;
    }
    
    public LocalDateTime getOperationTime() {
        return operationTime;
    }
    
    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }
    
    public LocalDateTime getCreateTime() {
        return createTime;
    }
}
